%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PRACTICA 3
% Autor: JESUS ESTEVEZ CAPARROS 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ejercicio 1:
%  Definir el predicado encadena(Lista1,Lista2,Lista3) que encadena 
%   la Lista1 y la Lista2 y devuelve el resultado en la Lista3.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

encadena([],L1,L1).
        encadena([Cabeza|Cola],L1,[Cabeza|Cola2]):-
                encadena(Cola,L1,Cola2).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ejercicio 2:
%       Definir el predicado fibonacci
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                              
fibonacci(0,1).
fibonacci(1,1).
fibonacci(X,Y):-
        X>1 ,
                X1 is X - 1, fibonacci(X1,Y1),
                X2 is X - 2, fibonacci(X2,Y2),
                Y is Y1 + Y2.